package org.django4j;

import javax.servlet.http.HttpServletResponse;

public class Django4jException extends RuntimeException {
    private static final long serialVersionUID = -8899553167427760412L;
    private int statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;

    public Django4jException(String message, Throwable t){
        super(message);
        super.initCause(t);
    }
    
    public Django4jException(Throwable t){
        super(t.getClass().getName() + ": " +  t.getMessage());
        super.initCause(t);
    }
    
    public Django4jException(String message){
        super(message);
    }
    
    public Django4jException(int statusCode, String message, Throwable t){
        this(message, t);
        this.statusCode = statusCode;
    }
    
    public Django4jException(int statusCode, Throwable t){
        this(t);
        this.statusCode = statusCode;
    }
    
    public Django4jException(int statusCode, String message){
        this(message);
        this.statusCode = statusCode;
    }    
    
    public int getStatusCode(){
        return this.statusCode;
    }
    
    public String toString(){
        StringBuffer buffer  = new StringBuffer();
        buffer.append("<Exception>").append(this.getMessage()).append("</Exception>");
        return buffer.toString();
    }
}
